\hypertarget{bus_8h}{
\section{wmv\_\-bus/bus.h File Reference}
\label{bus_8h}\index{wmv\_\-bus/bus.h@{wmv\_\-bus/bus.h}}
}
The communication bus protocol used in the openASC project.  


\subsection*{Classes}
\begin{CompactItemize}
\item 
struct \hyperlink{structBUS__MESSAGE}{BUS\_\-MESSAGE}
\item 
struct \hyperlink{structrx__linked__list}{rx\_\-linked\_\-list}
\begin{CompactList}\small\item\em The structure of the RX circular buffer. \item\end{CompactList}\item 
struct \hyperlink{structtx__linked__list}{tx\_\-linked\_\-list}
\begin{CompactList}\small\item\em The structure of the TX circular buffer. \item\end{CompactList}\item 
struct \hyperlink{structbus__status__struct}{bus\_\-status\_\-struct}
\end{CompactItemize}
\subsection*{Defines}
\begin{CompactItemize}
\item 
\#define \hyperlink{bus_8h_14379db1c0e7d2b141c5c79b654046fa}{DEF\_\-NR\_\-DEVICES}~25
\begin{CompactList}\small\item\em Define the proper interrupt routines depending on hardware. \item\end{CompactList}\item 
\hypertarget{bus_8h_6d14e83bdbd2c140169665ded6befffd}{
\#define \hyperlink{bus_8h_6d14e83bdbd2c140169665ded6befffd}{DEFAULT\_\-STARTUP\_\-DELAY}~90}
\label{bus_8h_6d14e83bdbd2c140169665ded6befffd}

\begin{CompactList}\small\item\em The startup time for the device. This is so that all units dont send ping at the same time. \item\end{CompactList}\item 
\#define \hyperlink{bus_8h_745f0f43205404fd4fb90176db54da84}{BUS\_\-MSG\_\-PREAMBLE}~0xFE
\item 
\#define \hyperlink{bus_8h_837db7e8a269db9d24d01d5d2f20f666}{BUS\_\-MSG\_\-POSTAMBLE}~0xFD
\item 
\#define \hyperlink{bus_8h_d5963e8d59fa0adb58ed714382363577}{BUS\_\-MSG\_\-ACK}~0xFA
\item 
\#define \hyperlink{bus_8h_aa67432524edc62d9a071161984c8167}{BUS\_\-MSG\_\-NACK}~0xFB
\item 
\#define \hyperlink{bus_8h_6249520d08d6d922ac9c4f2ce86427e6}{BUS\_\-BROADCAST\_\-ADDR}~0x00
\item 
\hypertarget{bus_8h_63462d2a163fc2856a91a4ed6feb275e}{
\#define \hyperlink{bus_8h_63462d2a163fc2856a91a4ed6feb275e}{DEVICE\_\-ID\_\-MAINBOX}~1}
\label{bus_8h_63462d2a163fc2856a91a4ed6feb275e}

\begin{CompactList}\small\item\em Device ID for the mainbox. \item\end{CompactList}\item 
\hypertarget{bus_8h_8b52fe22425a13f9344f6d85903a0540}{
\#define \hyperlink{bus_8h_8b52fe22425a13f9344f6d85903a0540}{DEVICE\_\-ID\_\-DRIVER\_\-POS}~2}
\label{bus_8h_8b52fe22425a13f9344f6d85903a0540}

\begin{CompactList}\small\item\em Device ID for the positive driver module. \item\end{CompactList}\item 
\hypertarget{bus_8h_1ac051e1399e4c2f7db8fcdcdd3ad197}{
\#define \hyperlink{bus_8h_1ac051e1399e4c2f7db8fcdcdd3ad197}{DEVICE\_\-ID\_\-DRIVER\_\-NEG}~3}
\label{bus_8h_1ac051e1399e4c2f7db8fcdcdd3ad197}

\begin{CompactList}\small\item\em Device ID for the negative driver module. \item\end{CompactList}\item 
\hypertarget{bus_8h_b695a1867f19a15b9a0c59bef13a81ac}{
\#define \hyperlink{bus_8h_b695a1867f19a15b9a0c59bef13a81ac}{DEVICE\_\-ID\_\-ROTATOR\_\-UNIT}~4}
\label{bus_8h_b695a1867f19a15b9a0c59bef13a81ac}

\begin{CompactList}\small\item\em Device ID for the rotator unit. \item\end{CompactList}\item 
\hypertarget{bus_8h_c0ea409622c3bc3c8e7de55325d6e6e8}{
\#define \hyperlink{bus_8h_c0ea409622c3bc3c8e7de55325d6e6e8}{DEVICE\_\-ID\_\-COMPUTER}~5}
\label{bus_8h_c0ea409622c3bc3c8e7de55325d6e6e8}

\begin{CompactList}\small\item\em Device ID for a computer. \item\end{CompactList}\item 
\hypertarget{bus_8h_847c4f6a6e898333397c83acabef562f}{
\#define \hyperlink{bus_8h_847c4f6a6e898333397c83acabef562f}{DEVICE\_\-ID\_\-POWERMETER\_\-PICKUP}~6}
\label{bus_8h_847c4f6a6e898333397c83acabef562f}

\begin{CompactList}\small\item\em Device ID for a power meter pickup. \item\end{CompactList}\item 
\hypertarget{bus_8h_5ebed536e93fff07b766b6390296c8bc}{
\#define \hyperlink{bus_8h_5ebed536e93fff07b766b6390296c8bc}{DEVICE\_\-ID\_\-GENERAL\_\-IO}~7}
\label{bus_8h_5ebed536e93fff07b766b6390296c8bc}

\begin{CompactList}\small\item\em Device ID for the General I/O card. \item\end{CompactList}\item 
\#define \hyperlink{bus_8h_a5a11702bff91f1a9e630f6b40953f3a}{BUS\_\-MAX\_\-RESENDS}~10
\item 
\#define \hyperlink{bus_8h_f21521f2eb3f795fc45cd827290c18ff}{BUS\_\-DEVICE\_\-STATUS\_\-MESSAGE\_\-INTERVAL}~1500
\item 
\#define \hyperlink{bus_8h_c6fbbe2929d0958f44d99a73f4055591}{BUS\_\-MASTER\_\-SYNC\_\-INTERVAL}~1000
\item 
\#define \hyperlink{bus_8h_8254b281c8987922cd11d6ddd74fca6a}{BUS\_\-SYNC\_\-TIMEOUT\_\-LIMIT}~3200
\item 
\#define \hyperlink{bus_8h_8045bc91156a876275574105a3040d6e}{BUS\_\-ACK\_\-WRAPAROUND\_\-LIMIT}~10
\item 
\#define \hyperlink{bus_8h_01a619776878e68496fac136cae92e3b}{BUS\_\-TIMEOUT\_\-LIMIT}~5
\item 
\#define \hyperlink{bus_8h_e053fff2a62fe9f1db3ade6114954f79}{BUS\_\-STATUS\_\-DEVICE\_\-IS\_\-MASTER\_\-BIT}~0
\item 
\#define \hyperlink{bus_8h_ce9e759febab1ef55a06836baff54dcb}{BUS\_\-STATUS\_\-ALLOWED\_\-TO\_\-SEND\_\-BIT}~1
\item 
\#define \hyperlink{bus_8h_6a16221d27bb7882638936437408b9fa}{BUS\_\-STATUS\_\-PREAMBLE\_\-FOUND\_\-BIT}~2
\item 
\#define \hyperlink{bus_8h_07ac20bb9da5a0d2178ade0e7e2a1055}{BUS\_\-STATUS\_\-MASTER\_\-SENT\_\-SYNC\_\-BIT}~3
\item 
\#define \hyperlink{bus_8h_d929cddec5866e51ae46f2b1146a3a0a}{BUS\_\-STATUS\_\-TIME\_\-SLOT\_\-ACTIVE}~4
\item 
\#define \hyperlink{bus_8h_ad5b06797adce7aad2eae7d9fa070bc7}{BUS\_\-STATUS\_\-SEND\_\-MESSAGE}~5
\item 
\#define \hyperlink{bus_8h_35bd108336fd649fd8e73a4e9c4a00d6}{BUS\_\-STATUS\_\-SEND\_\-ACTIVE}~6
\item 
\#define \hyperlink{bus_8h_6305d4de08e065ad7a9851ee739c554c}{BUS\_\-STATUS\_\-RECEIVE\_\-ON}~7
\item 
\#define \hyperlink{bus_8h_716f8bf40ec0a741389c83fbe7a36b25}{BUS\_\-STATUS\_\-FORCE\_\-SYNC}~8
\item 
\#define \hyperlink{bus_8h_079d5caf6326a9b8c706e34790c67a4d}{BUS\_\-STATUS\_\-MESSAGE\_\-ACK\_\-TIMEOUT}~9
\item 
\#define \hyperlink{bus_8h_550ae920e5b20b393e223b9af411d9f9}{BUS\_\-TIME\_\-MULTIPLIER}~4
\item 
\#define \hyperlink{bus_8h_81e5cc7dd49cfdc283046c4c19da3423}{BUS\_\-TIME\_\-INTERRUPT\_\-INTERVAL}~130
\item 
\#define \hyperlink{bus_8h_ee2d8d588aab76ec47e5a7819b5dd99d}{BUS\_\-TIME\_\-FRAME\_\-LIMIT}~520
\item 
\#define \hyperlink{bus_8h_3075ee8ff81a9a49b479684c40161fe4}{BUS\_\-SLOT\_\-DEAD\_\-TIME}~130
\item 
\hypertarget{bus_8h_c9beb1901b37c4deeea22c09c6e8042b}{
\#define \hyperlink{bus_8h_c9beb1901b37c4deeea22c09c6e8042b}{SERIAL\_\-RX\_\-BUF\_\-LENGTH}~20}
\label{bus_8h_c9beb1901b37c4deeea22c09c6e8042b}

\begin{CompactList}\small\item\em Length of the RX buffer. \item\end{CompactList}\item 
\hypertarget{bus_8h_44c9bb9b0c95a00e1322c942aa7dca39}{
\#define \hyperlink{bus_8h_44c9bb9b0c95a00e1322c942aa7dca39}{BUS\_\-MESSAGE\_\-DATA\_\-SIZE}~15}
\label{bus_8h_44c9bb9b0c95a00e1322c942aa7dca39}

\begin{CompactList}\small\item\em Define the length of the bus message data field length. \item\end{CompactList}\item 
\#define \hyperlink{bus_8h_76bcceff22cba96905957274b8265298}{BUS\_\-MESSAGE\_\-FLAGS\_\-NEED\_\-ACK}~0
\item 
\hypertarget{bus_8h_d303c5913fdb4681de77bfd3a65064c6}{
\#define \hyperlink{bus_8h_d303c5913fdb4681de77bfd3a65064c6}{BUS\_\-CHECKSUM\_\-ERROR}~0}
\label{bus_8h_d303c5913fdb4681de77bfd3a65064c6}

\begin{CompactList}\small\item\em BUS ERRORs. \item\end{CompactList}\end{CompactItemize}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
\hypertarget{bus_8h_bdfca8676e032bf7299a77bd89be379e}{
typedef struct \hyperlink{structrx__linked__list}{rx\_\-linked\_\-list} \hyperlink{bus_8h_bdfca8676e032bf7299a77bd89be379e}{rx\_\-queue\_\-struct}}
\label{bus_8h_bdfca8676e032bf7299a77bd89be379e}

\begin{CompactList}\small\item\em The structure of the RX circular buffer. \item\end{CompactList}\item 
\hypertarget{bus_8h_02ede1cbaea86d95bfae901531bc9d67}{
typedef struct \hyperlink{structtx__linked__list}{tx\_\-linked\_\-list} \hyperlink{bus_8h_02ede1cbaea86d95bfae901531bc9d67}{tx\_\-queue\_\-struct}}
\label{bus_8h_02ede1cbaea86d95bfae901531bc9d67}

\begin{CompactList}\small\item\em The structure of the TX circular buffer. \item\end{CompactList}\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
void \hyperlink{bus_8h_4c78398b39ca1a317bcd94e32d3238ed}{bus\_\-add\_\-tx\_\-message} (unsigned char from\_\-addr, unsigned char to\_\-addr, unsigned char flags, unsigned char cmd, unsigned char length, unsigned char data\mbox{[}$\,$\mbox{]})
\begin{CompactList}\small\item\em Adds a message to the TX queue which will be sent as soon as possible. \item\end{CompactList}\item 
void \hyperlink{bus_8h_8900b6684889df452076e67b3a528bc8}{bus\_\-add\_\-rx\_\-message} (unsigned char from\_\-addr, unsigned char to\_\-addr, unsigned char flags, unsigned char cmd, unsigned char length, unsigned char data\mbox{[}$\,$\mbox{]})
\begin{CompactList}\small\item\em Adds a message to the RX queue which will be sent as soon as possible. \item\end{CompactList}\item 
void \hyperlink{bus_8h_9869a6434da36c0bfa8573d68bed9b40}{bus\_\-set\_\-address} (unsigned char addr)
\begin{CompactList}\small\item\em Set the address of this device on the bus. \item\end{CompactList}\item 
unsigned char \hyperlink{bus_8h_978d35e07c79199b121997d80de56655}{bus\_\-get\_\-address} (void)
\begin{CompactList}\small\item\em Returns the address of this device. \item\end{CompactList}\item 
\hypertarget{bus_8h_66e8708f99633602ea17873c9bed4b6d}{
void \hyperlink{bus_8h_66e8708f99633602ea17873c9bed4b6d}{bus\_\-init} (void)}
\label{bus_8h_66e8708f99633602ea17873c9bed4b6d}

\begin{CompactList}\small\item\em Init the communication bus. \item\end{CompactList}\item 
\hypertarget{bus_8h_2e40ef066b1f7231f314bc85779110ed}{
void \hyperlink{bus_8h_2e40ef066b1f7231f314bc85779110ed}{bus\_\-resend\_\-message} (void)}
\label{bus_8h_2e40ef066b1f7231f314bc85779110ed}

\begin{CompactList}\small\item\em Resend the last message. \item\end{CompactList}\item 
\hypertarget{bus_8h_069826b2c00193de5883c42ffc8c95fc}{
void \hyperlink{bus_8h_069826b2c00193de5883c42ffc8c95fc}{bus\_\-send\_\-ack} (unsigned char to\_\-addr)}
\label{bus_8h_069826b2c00193de5883c42ffc8c95fc}

\begin{CompactList}\small\item\em Send an acknowledge. \item\end{CompactList}\item 
void \hyperlink{bus_8h_651be0f483dc1e17174069bbf991d653}{bus\_\-send\_\-nack} (unsigned char to\_\-addr, unsigned char error\_\-type)
\begin{CompactList}\small\item\em Send an NOT acknowledge. \item\end{CompactList}\item 
\hypertarget{bus_8h_205fdad7d74dbd67e7b31c9630819cb9}{
void \hyperlink{bus_8h_205fdad7d74dbd67e7b31c9630819cb9}{bus\_\-message\_\-acked} (unsigned char addr)}
\label{bus_8h_205fdad7d74dbd67e7b31c9630819cb9}

\begin{CompactList}\small\item\em The message last sent was acknowledged from the receiver. \item\end{CompactList}\item 
void \hyperlink{bus_8h_4541ef9a75addac3aaa4af88d8f03590}{bus\_\-message\_\-nacked} (unsigned char addr, unsigned char error\_\-type)
\begin{CompactList}\small\item\em The message last sent was NACKED from the receiver. \item\end{CompactList}\item 
\hypertarget{bus_8h_1f8ed281f15b4e6e34cdcdb2bfb70932}{
void \_\-\_\-inline\_\-\_\- \hyperlink{bus_8h_1f8ed281f15b4e6e34cdcdb2bfb70932}{bus\_\-reset\_\-tx\_\-status} (void)}
\label{bus_8h_1f8ed281f15b4e6e34cdcdb2bfb70932}

\begin{CompactList}\small\item\em Function that resets the bus status variables. \item\end{CompactList}\item 
\hypertarget{bus_8h_524ab9ee02e43dff455677fdecfb5e21}{
void \_\-\_\-inline\_\-\_\- \hyperlink{bus_8h_524ab9ee02e43dff455677fdecfb5e21}{bus\_\-reset\_\-rx\_\-status} (void)}
\label{bus_8h_524ab9ee02e43dff455677fdecfb5e21}

\begin{CompactList}\small\item\em Function that resets the bus status variables. \item\end{CompactList}\item 
unsigned char \hyperlink{bus_8h_ce52a77ee7a62558643de23c5f10f9c7}{bus\_\-is\_\-master} (void)
\begin{CompactList}\small\item\em Returns if the bus is set to be master. \item\end{CompactList}\item 
void \hyperlink{bus_8h_ed493aabe32ac3eaafb77d4c23f15eb9}{bus\_\-set\_\-is\_\-master} (unsigned char state, unsigned char count)
\begin{CompactList}\small\item\em Set the status if the device should be master or not. \item\end{CompactList}\item 
unsigned char \hyperlink{bus_8h_76f9639571632344a2a1ae4138663667}{bus\_\-get\_\-device\_\-count} (void)
\begin{CompactList}\small\item\em Receive the device count on the bus. \item\end{CompactList}\item 
void \hyperlink{bus_8h_bbcb4456ec66651e191189cc985bfeab}{bus\_\-set\_\-device\_\-count} (unsigned char \hyperlink{front__panel_2main_8c_4e659bfe570f8e58593672bc9a8d22a7}{device\_\-count})
\begin{CompactList}\small\item\em Set the number of devices that are on the bus. \item\end{CompactList}\item 
unsigned char \hyperlink{bus_8h_ceb215ff9ef4810ef00434c1c02f6a4c}{bus\_\-allowed\_\-to\_\-send} (void)
\begin{CompactList}\small\item\em Returns if you are allowed to transmit data to the bus or not. \item\end{CompactList}\item 
\hypertarget{bus_8h_370f257e97b9adc5aeb57ef539ce8547}{
void \hyperlink{bus_8h_370f257e97b9adc5aeb57ef539ce8547}{bus\_\-check\_\-tx\_\-status} (void)}
\label{bus_8h_370f257e97b9adc5aeb57ef539ce8547}

\begin{CompactList}\small\item\em Checks if there is anything that should be sent in the TX queue. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
The communication bus protocol used in the openASC project. 



Definition in file \hyperlink{bus_8h-source}{bus.h}.

\subsection{Define Documentation}
\hypertarget{bus_8h_8045bc91156a876275574105a3040d6e}{
\index{bus.h@{bus.h}!BUS\_\-ACK\_\-WRAPAROUND\_\-LIMIT@{BUS\_\-ACK\_\-WRAPAROUND\_\-LIMIT}}
\index{BUS\_\-ACK\_\-WRAPAROUND\_\-LIMIT@{BUS\_\-ACK\_\-WRAPAROUND\_\-LIMIT}!bus.h@{bus.h}}
\subsubsection[{BUS\_\-ACK\_\-WRAPAROUND\_\-LIMIT}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUS\_\-ACK\_\-WRAPAROUND\_\-LIMIT~10}}
\label{bus_8h_8045bc91156a876275574105a3040d6e}


The timeout limit between a message that was sent to when it will be a resend, this is counted as number of wraparounds on the bus, ie 5 would mean 5 wraparounds 

Definition at line 171 of file bus.h.

Referenced by ISR().\hypertarget{bus_8h_6249520d08d6d922ac9c4f2ce86427e6}{
\index{bus.h@{bus.h}!BUS\_\-BROADCAST\_\-ADDR@{BUS\_\-BROADCAST\_\-ADDR}}
\index{BUS\_\-BROADCAST\_\-ADDR@{BUS\_\-BROADCAST\_\-ADDR}!bus.h@{bus.h}}
\subsubsection[{BUS\_\-BROADCAST\_\-ADDR}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUS\_\-BROADCAST\_\-ADDR~0x00}}
\label{bus_8h_6249520d08d6d922ac9c4f2ce86427e6}


Bus broadcast address - All broadcast messages should contain an ID explaining which kind of device that is sending the message 

Definition at line 137 of file bus.h.

Referenced by bus\_\-send\_\-message(), bus\_\-send\_\-nack(), ISR(), main(), and send\_\-ping().\hypertarget{bus_8h_f21521f2eb3f795fc45cd827290c18ff}{
\index{bus.h@{bus.h}!BUS\_\-DEVICE\_\-STATUS\_\-MESSAGE\_\-INTERVAL@{BUS\_\-DEVICE\_\-STATUS\_\-MESSAGE\_\-INTERVAL}}
\index{BUS\_\-DEVICE\_\-STATUS\_\-MESSAGE\_\-INTERVAL@{BUS\_\-DEVICE\_\-STATUS\_\-MESSAGE\_\-INTERVAL}!bus.h@{bus.h}}
\subsubsection[{BUS\_\-DEVICE\_\-STATUS\_\-MESSAGE\_\-INTERVAL}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUS\_\-DEVICE\_\-STATUS\_\-MESSAGE\_\-INTERVAL~1500}}
\label{bus_8h_f21521f2eb3f795fc45cd827290c18ff}


The interval between each status message (time is in ms) 

Definition at line 158 of file bus.h.

Referenced by ISR(), and main().\hypertarget{bus_8h_c6fbbe2929d0958f44d99a73f4055591}{
\index{bus.h@{bus.h}!BUS\_\-MASTER\_\-SYNC\_\-INTERVAL@{BUS\_\-MASTER\_\-SYNC\_\-INTERVAL}}
\index{BUS\_\-MASTER\_\-SYNC\_\-INTERVAL@{BUS\_\-MASTER\_\-SYNC\_\-INTERVAL}!bus.h@{bus.h}}
\subsubsection[{BUS\_\-MASTER\_\-SYNC\_\-INTERVAL}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUS\_\-MASTER\_\-SYNC\_\-INTERVAL~1000}}
\label{bus_8h_c6fbbe2929d0958f44d99a73f4055591}


The interval which the SYNC command is sent out from the master (time in ms) This value is not allowed to be over 5000 ms since that will make it too big for the timer controlling the SYNC timeout on all the devices. 

Definition at line 163 of file bus.h.

Referenced by main().\hypertarget{bus_8h_a5a11702bff91f1a9e630f6b40953f3a}{
\index{bus.h@{bus.h}!BUS\_\-MAX\_\-RESENDS@{BUS\_\-MAX\_\-RESENDS}}
\index{BUS\_\-MAX\_\-RESENDS@{BUS\_\-MAX\_\-RESENDS}!bus.h@{bus.h}}
\subsubsection[{BUS\_\-MAX\_\-RESENDS}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUS\_\-MAX\_\-RESENDS~10}}
\label{bus_8h_a5a11702bff91f1a9e630f6b40953f3a}


The number of times a message is resent before it's dropped and an error flag is set 

Definition at line 155 of file bus.h.

Referenced by bus\_\-resend\_\-message().\hypertarget{bus_8h_76bcceff22cba96905957274b8265298}{
\index{bus.h@{bus.h}!BUS\_\-MESSAGE\_\-FLAGS\_\-NEED\_\-ACK@{BUS\_\-MESSAGE\_\-FLAGS\_\-NEED\_\-ACK}}
\index{BUS\_\-MESSAGE\_\-FLAGS\_\-NEED\_\-ACK@{BUS\_\-MESSAGE\_\-FLAGS\_\-NEED\_\-ACK}!bus.h@{bus.h}}
\subsubsection[{BUS\_\-MESSAGE\_\-FLAGS\_\-NEED\_\-ACK}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUS\_\-MESSAGE\_\-FLAGS\_\-NEED\_\-ACK~0}}
\label{bus_8h_76bcceff22cba96905957274b8265298}


BUS MESSAGE flags The message should be ACKED 

Definition at line 218 of file bus.h.

Referenced by antenna\_\-ctrl\_\-deactivate\_\-outputs(), antenna\_\-ctrl\_\-send\_\-ant\_\-data\_\-to\_\-bus(), antenna\_\-ctrl\_\-send\_\-rx\_\-ant\_\-band\_\-data\_\-to\_\-bus(), antenna\_\-ctrl\_\-send\_\-rx\_\-ant\_\-data\_\-to\_\-bus(), band\_\-ctrl\_\-send\_\-band\_\-data\_\-to\_\-bus(), ISR(), and sub\_\-menu\_\-send\_\-data\_\-to\_\-bus().\hypertarget{bus_8h_d5963e8d59fa0adb58ed714382363577}{
\index{bus.h@{bus.h}!BUS\_\-MSG\_\-ACK@{BUS\_\-MSG\_\-ACK}}
\index{BUS\_\-MSG\_\-ACK@{BUS\_\-MSG\_\-ACK}!bus.h@{bus.h}}
\subsubsection[{BUS\_\-MSG\_\-ACK}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUS\_\-MSG\_\-ACK~0xFA}}
\label{bus_8h_d5963e8d59fa0adb58ed714382363577}


The acknowledge command of the bus 

Definition at line 131 of file bus.h.\hypertarget{bus_8h_aa67432524edc62d9a071161984c8167}{
\index{bus.h@{bus.h}!BUS\_\-MSG\_\-NACK@{BUS\_\-MSG\_\-NACK}}
\index{BUS\_\-MSG\_\-NACK@{BUS\_\-MSG\_\-NACK}!bus.h@{bus.h}}
\subsubsection[{BUS\_\-MSG\_\-NACK}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUS\_\-MSG\_\-NACK~0xFB}}
\label{bus_8h_aa67432524edc62d9a071161984c8167}


The NOT acknowledge command of the bus 

Definition at line 133 of file bus.h.\hypertarget{bus_8h_837db7e8a269db9d24d01d5d2f20f666}{
\index{bus.h@{bus.h}!BUS\_\-MSG\_\-POSTAMBLE@{BUS\_\-MSG\_\-POSTAMBLE}}
\index{BUS\_\-MSG\_\-POSTAMBLE@{BUS\_\-MSG\_\-POSTAMBLE}!bus.h@{bus.h}}
\subsubsection[{BUS\_\-MSG\_\-POSTAMBLE}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUS\_\-MSG\_\-POSTAMBLE~0xFD}}
\label{bus_8h_837db7e8a269db9d24d01d5d2f20f666}


The postamble of the BUS message 

Definition at line 129 of file bus.h.

Referenced by bus\_\-send\_\-message().\hypertarget{bus_8h_745f0f43205404fd4fb90176db54da84}{
\index{bus.h@{bus.h}!BUS\_\-MSG\_\-PREAMBLE@{BUS\_\-MSG\_\-PREAMBLE}}
\index{BUS\_\-MSG\_\-PREAMBLE@{BUS\_\-MSG\_\-PREAMBLE}!bus.h@{bus.h}}
\subsubsection[{BUS\_\-MSG\_\-PREAMBLE}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUS\_\-MSG\_\-PREAMBLE~0xFE}}
\label{bus_8h_745f0f43205404fd4fb90176db54da84}


The preamble of the BUS message 

Definition at line 127 of file bus.h.

Referenced by bus\_\-send\_\-message().\hypertarget{bus_8h_3075ee8ff81a9a49b479684c40161fe4}{
\index{bus.h@{bus.h}!BUS\_\-SLOT\_\-DEAD\_\-TIME@{BUS\_\-SLOT\_\-DEAD\_\-TIME}}
\index{BUS\_\-SLOT\_\-DEAD\_\-TIME@{BUS\_\-SLOT\_\-DEAD\_\-TIME}!bus.h@{bus.h}}
\subsubsection[{BUS\_\-SLOT\_\-DEAD\_\-TIME}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUS\_\-SLOT\_\-DEAD\_\-TIME~130}}
\label{bus_8h_3075ee8ff81a9a49b479684c40161fe4}


The dead time of the time slot, in us. This should be set pretty high to accept rather high clock drift There is a dead period both before and after our slot, so total dead time is BUS\_\-SLOT\_\-DEAD\_\-TIME $\ast$ 2 

Definition at line 208 of file bus.h.

Referenced by bus\_\-init().\hypertarget{bus_8h_ce9e759febab1ef55a06836baff54dcb}{
\index{bus.h@{bus.h}!BUS\_\-STATUS\_\-ALLOWED\_\-TO\_\-SEND\_\-BIT@{BUS\_\-STATUS\_\-ALLOWED\_\-TO\_\-SEND\_\-BIT}}
\index{BUS\_\-STATUS\_\-ALLOWED\_\-TO\_\-SEND\_\-BIT@{BUS\_\-STATUS\_\-ALLOWED\_\-TO\_\-SEND\_\-BIT}!bus.h@{bus.h}}
\subsubsection[{BUS\_\-STATUS\_\-ALLOWED\_\-TO\_\-SEND\_\-BIT}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUS\_\-STATUS\_\-ALLOWED\_\-TO\_\-SEND\_\-BIT~1}}
\label{bus_8h_ce9e759febab1ef55a06836baff54dcb}


This bit shows if it's allowed to send messages on the bus, ie first sync has been received 

Definition at line 181 of file bus.h.\hypertarget{bus_8h_e053fff2a62fe9f1db3ade6114954f79}{
\index{bus.h@{bus.h}!BUS\_\-STATUS\_\-DEVICE\_\-IS\_\-MASTER\_\-BIT@{BUS\_\-STATUS\_\-DEVICE\_\-IS\_\-MASTER\_\-BIT}}
\index{BUS\_\-STATUS\_\-DEVICE\_\-IS\_\-MASTER\_\-BIT@{BUS\_\-STATUS\_\-DEVICE\_\-IS\_\-MASTER\_\-BIT}!bus.h@{bus.h}}
\subsubsection[{BUS\_\-STATUS\_\-DEVICE\_\-IS\_\-MASTER\_\-BIT}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUS\_\-STATUS\_\-DEVICE\_\-IS\_\-MASTER\_\-BIT~0}}
\label{bus_8h_e053fff2a62fe9f1db3ade6114954f79}


This bit is to set if the device is MASTER in the bus\_\-status.flags variable 

Definition at line 179 of file bus.h.

Referenced by bus\_\-is\_\-master(), and bus\_\-set\_\-is\_\-master().\hypertarget{bus_8h_716f8bf40ec0a741389c83fbe7a36b25}{
\index{bus.h@{bus.h}!BUS\_\-STATUS\_\-FORCE\_\-SYNC@{BUS\_\-STATUS\_\-FORCE\_\-SYNC}}
\index{BUS\_\-STATUS\_\-FORCE\_\-SYNC@{BUS\_\-STATUS\_\-FORCE\_\-SYNC}!bus.h@{bus.h}}
\subsubsection[{BUS\_\-STATUS\_\-FORCE\_\-SYNC}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUS\_\-STATUS\_\-FORCE\_\-SYNC~8}}
\label{bus_8h_716f8bf40ec0a741389c83fbe7a36b25}


This bit is to force a SYNC message to be sent 

Definition at line 195 of file bus.h.

Referenced by bus\_\-check\_\-tx\_\-status(), and bus\_\-set\_\-is\_\-master().\hypertarget{bus_8h_07ac20bb9da5a0d2178ade0e7e2a1055}{
\index{bus.h@{bus.h}!BUS\_\-STATUS\_\-MASTER\_\-SENT\_\-SYNC\_\-BIT@{BUS\_\-STATUS\_\-MASTER\_\-SENT\_\-SYNC\_\-BIT}}
\index{BUS\_\-STATUS\_\-MASTER\_\-SENT\_\-SYNC\_\-BIT@{BUS\_\-STATUS\_\-MASTER\_\-SENT\_\-SYNC\_\-BIT}!bus.h@{bus.h}}
\subsubsection[{BUS\_\-STATUS\_\-MASTER\_\-SENT\_\-SYNC\_\-BIT}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUS\_\-STATUS\_\-MASTER\_\-SENT\_\-SYNC\_\-BIT~3}}
\label{bus_8h_07ac20bb9da5a0d2178ade0e7e2a1055}


This bit is to set if the MASTER has sent a SYNC message so we are allowed to start sending 

Definition at line 185 of file bus.h.

Referenced by bus\_\-allowed\_\-to\_\-send(), and ISR().\hypertarget{bus_8h_079d5caf6326a9b8c706e34790c67a4d}{
\index{bus.h@{bus.h}!BUS\_\-STATUS\_\-MESSAGE\_\-ACK\_\-TIMEOUT@{BUS\_\-STATUS\_\-MESSAGE\_\-ACK\_\-TIMEOUT}}
\index{BUS\_\-STATUS\_\-MESSAGE\_\-ACK\_\-TIMEOUT@{BUS\_\-STATUS\_\-MESSAGE\_\-ACK\_\-TIMEOUT}!bus.h@{bus.h}}
\subsubsection[{BUS\_\-STATUS\_\-MESSAGE\_\-ACK\_\-TIMEOUT}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUS\_\-STATUS\_\-MESSAGE\_\-ACK\_\-TIMEOUT~9}}
\label{bus_8h_079d5caf6326a9b8c706e34790c67a4d}


This bit is to see if a message should be acked or not, used for the timeout of an acknowledge 

Definition at line 197 of file bus.h.

Referenced by bus\_\-message\_\-acked(), bus\_\-message\_\-nacked(), bus\_\-send\_\-message(), and ISR().\hypertarget{bus_8h_6a16221d27bb7882638936437408b9fa}{
\index{bus.h@{bus.h}!BUS\_\-STATUS\_\-PREAMBLE\_\-FOUND\_\-BIT@{BUS\_\-STATUS\_\-PREAMBLE\_\-FOUND\_\-BIT}}
\index{BUS\_\-STATUS\_\-PREAMBLE\_\-FOUND\_\-BIT@{BUS\_\-STATUS\_\-PREAMBLE\_\-FOUND\_\-BIT}!bus.h@{bus.h}}
\subsubsection[{BUS\_\-STATUS\_\-PREAMBLE\_\-FOUND\_\-BIT}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUS\_\-STATUS\_\-PREAMBLE\_\-FOUND\_\-BIT~2}}
\label{bus_8h_6a16221d27bb7882638936437408b9fa}


This bit is set if the preamble is found in the bus\_\-status.flags variable 

Definition at line 183 of file bus.h.\hypertarget{bus_8h_6305d4de08e065ad7a9851ee739c554c}{
\index{bus.h@{bus.h}!BUS\_\-STATUS\_\-RECEIVE\_\-ON@{BUS\_\-STATUS\_\-RECEIVE\_\-ON}}
\index{BUS\_\-STATUS\_\-RECEIVE\_\-ON@{BUS\_\-STATUS\_\-RECEIVE\_\-ON}!bus.h@{bus.h}}
\subsubsection[{BUS\_\-STATUS\_\-RECEIVE\_\-ON}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUS\_\-STATUS\_\-RECEIVE\_\-ON~7}}
\label{bus_8h_6305d4de08e065ad7a9851ee739c554c}


This bit is to indicate that we are CURRENTLY receiving a message 

Definition at line 193 of file bus.h.

Referenced by bus\_\-init(), bus\_\-send\_\-message(), and ISR().\hypertarget{bus_8h_35bd108336fd649fd8e73a4e9c4a00d6}{
\index{bus.h@{bus.h}!BUS\_\-STATUS\_\-SEND\_\-ACTIVE@{BUS\_\-STATUS\_\-SEND\_\-ACTIVE}}
\index{BUS\_\-STATUS\_\-SEND\_\-ACTIVE@{BUS\_\-STATUS\_\-SEND\_\-ACTIVE}!bus.h@{bus.h}}
\subsubsection[{BUS\_\-STATUS\_\-SEND\_\-ACTIVE}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUS\_\-STATUS\_\-SEND\_\-ACTIVE~6}}
\label{bus_8h_35bd108336fd649fd8e73a4e9c4a00d6}


This bit is to indicate that we are CURRENTLY sending a message 

Definition at line 191 of file bus.h.

Referenced by bus\_\-send\_\-message(), and ISR().\hypertarget{bus_8h_ad5b06797adce7aad2eae7d9fa070bc7}{
\index{bus.h@{bus.h}!BUS\_\-STATUS\_\-SEND\_\-MESSAGE@{BUS\_\-STATUS\_\-SEND\_\-MESSAGE}}
\index{BUS\_\-STATUS\_\-SEND\_\-MESSAGE@{BUS\_\-STATUS\_\-SEND\_\-MESSAGE}!bus.h@{bus.h}}
\subsubsection[{BUS\_\-STATUS\_\-SEND\_\-MESSAGE}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUS\_\-STATUS\_\-SEND\_\-MESSAGE~5}}
\label{bus_8h_ad5b06797adce7aad2eae7d9fa070bc7}


This bit is to indicate that we should try to send the message currently in the TX queue 

Definition at line 189 of file bus.h.

Referenced by bus\_\-check\_\-tx\_\-status(), bus\_\-resend\_\-message(), and bus\_\-reset\_\-tx\_\-status().\hypertarget{bus_8h_d929cddec5866e51ae46f2b1146a3a0a}{
\index{bus.h@{bus.h}!BUS\_\-STATUS\_\-TIME\_\-SLOT\_\-ACTIVE@{BUS\_\-STATUS\_\-TIME\_\-SLOT\_\-ACTIVE}}
\index{BUS\_\-STATUS\_\-TIME\_\-SLOT\_\-ACTIVE@{BUS\_\-STATUS\_\-TIME\_\-SLOT\_\-ACTIVE}!bus.h@{bus.h}}
\subsubsection[{BUS\_\-STATUS\_\-TIME\_\-SLOT\_\-ACTIVE}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUS\_\-STATUS\_\-TIME\_\-SLOT\_\-ACTIVE~4}}
\label{bus_8h_d929cddec5866e51ae46f2b1146a3a0a}


This bit is to set if the device own time slot is currently active, ie it is possibly allowed to send 

Definition at line 187 of file bus.h.

Referenced by bus\_\-check\_\-tx\_\-status(), and ISR().\hypertarget{bus_8h_8254b281c8987922cd11d6ddd74fca6a}{
\index{bus.h@{bus.h}!BUS\_\-SYNC\_\-TIMEOUT\_\-LIMIT@{BUS\_\-SYNC\_\-TIMEOUT\_\-LIMIT}}
\index{BUS\_\-SYNC\_\-TIMEOUT\_\-LIMIT@{BUS\_\-SYNC\_\-TIMEOUT\_\-LIMIT}!bus.h@{bus.h}}
\subsubsection[{BUS\_\-SYNC\_\-TIMEOUT\_\-LIMIT}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUS\_\-SYNC\_\-TIMEOUT\_\-LIMIT~3200}}
\label{bus_8h_8254b281c8987922cd11d6ddd74fca6a}


This limit is used to detect if it was too long ago since we receieved a SYNC message from the master. If so it will stop with all outgoing communication. 

Definition at line 167 of file bus.h.

Referenced by ISR().\hypertarget{bus_8h_ee2d8d588aab76ec47e5a7819b5dd99d}{
\index{bus.h@{bus.h}!BUS\_\-TIME\_\-FRAME\_\-LIMIT@{BUS\_\-TIME\_\-FRAME\_\-LIMIT}}
\index{BUS\_\-TIME\_\-FRAME\_\-LIMIT@{BUS\_\-TIME\_\-FRAME\_\-LIMIT}!bus.h@{bus.h}}
\subsubsection[{BUS\_\-TIME\_\-FRAME\_\-LIMIT}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUS\_\-TIME\_\-FRAME\_\-LIMIT~520}}
\label{bus_8h_ee2d8d588aab76ec47e5a7819b5dd99d}


The time frame size of the bus time slots, in us 

Definition at line 205 of file bus.h.

Referenced by bus\_\-init().\hypertarget{bus_8h_81e5cc7dd49cfdc283046c4c19da3423}{
\index{bus.h@{bus.h}!BUS\_\-TIME\_\-INTERRUPT\_\-INTERVAL@{BUS\_\-TIME\_\-INTERRUPT\_\-INTERVAL}}
\index{BUS\_\-TIME\_\-INTERRUPT\_\-INTERVAL@{BUS\_\-TIME\_\-INTERRUPT\_\-INTERVAL}!bus.h@{bus.h}}
\subsubsection[{BUS\_\-TIME\_\-INTERRUPT\_\-INTERVAL}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUS\_\-TIME\_\-INTERRUPT\_\-INTERVAL~130}}
\label{bus_8h_81e5cc7dd49cfdc283046c4c19da3423}


The interval of the timer interrupts, in us 

Definition at line 203 of file bus.h.

Referenced by bus\_\-init().\hypertarget{bus_8h_550ae920e5b20b393e223b9af411d9f9}{
\index{bus.h@{bus.h}!BUS\_\-TIME\_\-MULTIPLIER@{BUS\_\-TIME\_\-MULTIPLIER}}
\index{BUS\_\-TIME\_\-MULTIPLIER@{BUS\_\-TIME\_\-MULTIPLIER}!bus.h@{bus.h}}
\subsubsection[{BUS\_\-TIME\_\-MULTIPLIER}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUS\_\-TIME\_\-MULTIPLIER~4}}
\label{bus_8h_550ae920e5b20b393e223b9af411d9f9}


This is the multiplier for the send window BUS\_\-TIME\_\-INTERRUPT\_\-INTERVAL $\ast$ BUS\_\-TIME\_\-MULTIPLIER = BUS\_\-TIME\_\-FRAME\_\-LIMIT 

Definition at line 201 of file bus.h.

Referenced by bus\_\-set\_\-device\_\-count(), bus\_\-set\_\-is\_\-master(), and ISR().\hypertarget{bus_8h_01a619776878e68496fac136cae92e3b}{
\index{bus.h@{bus.h}!BUS\_\-TIMEOUT\_\-LIMIT@{BUS\_\-TIMEOUT\_\-LIMIT}}
\index{BUS\_\-TIMEOUT\_\-LIMIT@{BUS\_\-TIMEOUT\_\-LIMIT}!bus.h@{bus.h}}
\subsubsection[{BUS\_\-TIMEOUT\_\-LIMIT}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUS\_\-TIMEOUT\_\-LIMIT~5}}
\label{bus_8h_01a619776878e68496fac136cae92e3b}


Timeout limit for how long it can take without receiving a message before the buffer is cleared, this is counted as time, 5 would mean 5 $\ast$ 130 us 

Definition at line 175 of file bus.h.

Referenced by ISR().\hypertarget{bus_8h_14379db1c0e7d2b141c5c79b654046fa}{
\index{bus.h@{bus.h}!DEF\_\-NR\_\-DEVICES@{DEF\_\-NR\_\-DEVICES}}
\index{DEF\_\-NR\_\-DEVICES@{DEF\_\-NR\_\-DEVICES}!bus.h@{bus.h}}
\subsubsection[{DEF\_\-NR\_\-DEVICES}]{\setlength{\rightskip}{0pt plus 5cm}\#define DEF\_\-NR\_\-DEVICES~25}}
\label{bus_8h_14379db1c0e7d2b141c5c79b654046fa}


Define the proper interrupt routines depending on hardware. 

The default number of devices 

Definition at line 121 of file bus.h.

Referenced by bus\_\-ping\_\-get\_\-failed\_\-count(), bus\_\-ping\_\-get\_\-failed\_\-ping(), bus\_\-ping\_\-init(), bus\_\-ping\_\-tick(), and main().

\subsection{Function Documentation}
\hypertarget{bus_8h_8900b6684889df452076e67b3a528bc8}{
\index{bus.h@{bus.h}!bus\_\-add\_\-rx\_\-message@{bus\_\-add\_\-rx\_\-message}}
\index{bus\_\-add\_\-rx\_\-message@{bus\_\-add\_\-rx\_\-message}!bus.h@{bus.h}}
\subsubsection[{bus\_\-add\_\-rx\_\-message}]{\setlength{\rightskip}{0pt plus 5cm}void bus\_\-add\_\-rx\_\-message (unsigned char {\em from\_\-addr}, \/  unsigned char {\em to\_\-addr}, \/  unsigned char {\em flags}, \/  unsigned char {\em cmd}, \/  unsigned char {\em length}, \/  unsigned char {\em data}\mbox{[}$\,$\mbox{]})}}
\label{bus_8h_8900b6684889df452076e67b3a528bc8}


Adds a message to the RX queue which will be sent as soon as possible. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em from\_\-addr}]The address of the sender \item[{\em to\_\-addr}]The address to the receiever \item[{\em flags}]Different flags, see defines \item[{\em cmd}]The command performed \item[{\em length}]The length of the data received \item[{\em data}]The data receieved \end{description}
\end{Desc}


Definition at line 324 of file bus.c.

References BUS\_\-MESSAGE::cmd, BUS\_\-MESSAGE::data, BUS\_\-MESSAGE::flags, BUS\_\-MESSAGE::from\_\-addr, BUS\_\-MESSAGE::length, rx\_\-queue\_\-add(), and BUS\_\-MESSAGE::to\_\-addr.\hypertarget{bus_8h_4c78398b39ca1a317bcd94e32d3238ed}{
\index{bus.h@{bus.h}!bus\_\-add\_\-tx\_\-message@{bus\_\-add\_\-tx\_\-message}}
\index{bus\_\-add\_\-tx\_\-message@{bus\_\-add\_\-tx\_\-message}!bus.h@{bus.h}}
\subsubsection[{bus\_\-add\_\-tx\_\-message}]{\setlength{\rightskip}{0pt plus 5cm}void bus\_\-add\_\-tx\_\-message (unsigned char {\em from\_\-addr}, \/  unsigned char {\em to\_\-addr}, \/  unsigned char {\em flags}, \/  unsigned char {\em cmd}, \/  unsigned char {\em length}, \/  unsigned char {\em data}\mbox{[}$\,$\mbox{]})}}
\label{bus_8h_4c78398b39ca1a317bcd94e32d3238ed}


Adds a message to the TX queue which will be sent as soon as possible. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em from\_\-addr}]The address of the sender \item[{\em to\_\-addr}]The address to the receiever \item[{\em flags}]Different flags, see defines \item[{\em cmd}]The command wanted to be performed \item[{\em length}]The length of the data wanting to be sent \item[{\em data}]The data wanted to be transmitted to the receiever \end{description}
\end{Desc}


Definition at line 291 of file bus.c.

References bus\_\-allowed\_\-to\_\-send(), BUS\_\-CMD\_\-SYNC, BUS\_\-MESSAGE::checksum, BUS\_\-MESSAGE::cmd, BUS\_\-MESSAGE::data, BUS\_\-MESSAGE::flags, BUS\_\-MESSAGE::from\_\-addr, BUS\_\-MESSAGE::length, BUS\_\-MESSAGE::to\_\-addr, and tx\_\-queue\_\-add().

Referenced by antenna\_\-ctrl\_\-deactivate\_\-outputs(), antenna\_\-ctrl\_\-send\_\-ant\_\-data\_\-to\_\-bus(), antenna\_\-ctrl\_\-send\_\-rx\_\-ant\_\-band\_\-data\_\-to\_\-bus(), antenna\_\-ctrl\_\-send\_\-rx\_\-ant\_\-data\_\-to\_\-bus(), band\_\-ctrl\_\-send\_\-band\_\-data\_\-to\_\-bus(), bus\_\-parse\_\-message(), bus\_\-send\_\-ack(), bus\_\-send\_\-nack(), ISR(), main(), send\_\-ping(), and sub\_\-menu\_\-send\_\-data\_\-to\_\-bus().\hypertarget{bus_8h_ceb215ff9ef4810ef00434c1c02f6a4c}{
\index{bus.h@{bus.h}!bus\_\-allowed\_\-to\_\-send@{bus\_\-allowed\_\-to\_\-send}}
\index{bus\_\-allowed\_\-to\_\-send@{bus\_\-allowed\_\-to\_\-send}!bus.h@{bus.h}}
\subsubsection[{bus\_\-allowed\_\-to\_\-send}]{\setlength{\rightskip}{0pt plus 5cm}unsigned char bus\_\-allowed\_\-to\_\-send (void)}}
\label{bus_8h_ceb215ff9ef4810ef00434c1c02f6a4c}


Returns if you are allowed to transmit data to the bus or not. 

\begin{Desc}
\item[Returns:]1 if it's allowed to transmit and 0 if not \end{Desc}


Definition at line 114 of file bus.c.

References BUS\_\-STATUS\_\-MASTER\_\-SENT\_\-SYNC\_\-BIT, and bus\_\-status\_\-struct::flags.

Referenced by bus\_\-add\_\-tx\_\-message(), ISR(), and main().\hypertarget{bus_8h_978d35e07c79199b121997d80de56655}{
\index{bus.h@{bus.h}!bus\_\-get\_\-address@{bus\_\-get\_\-address}}
\index{bus\_\-get\_\-address@{bus\_\-get\_\-address}!bus.h@{bus.h}}
\subsubsection[{bus\_\-get\_\-address}]{\setlength{\rightskip}{0pt plus 5cm}unsigned char bus\_\-get\_\-address (void)}}
\label{bus_8h_978d35e07c79199b121997d80de56655}


Returns the address of this device. 

\begin{Desc}
\item[Returns:]The address of this device \end{Desc}


Definition at line 123 of file bus.c.

References bus\_\-status\_\-struct::ext\_\-addr.

Referenced by antenna\_\-ctrl\_\-deactivate\_\-outputs(), antenna\_\-ctrl\_\-send\_\-ant\_\-data\_\-to\_\-bus(), antenna\_\-ctrl\_\-send\_\-rx\_\-ant\_\-band\_\-data\_\-to\_\-bus(), antenna\_\-ctrl\_\-send\_\-rx\_\-ant\_\-data\_\-to\_\-bus(), band\_\-ctrl\_\-send\_\-band\_\-data\_\-to\_\-bus(), bus\_\-parse\_\-message(), ISR(), main(), send\_\-ping(), and sub\_\-menu\_\-send\_\-data\_\-to\_\-bus().\hypertarget{bus_8h_76f9639571632344a2a1ae4138663667}{
\index{bus.h@{bus.h}!bus\_\-get\_\-device\_\-count@{bus\_\-get\_\-device\_\-count}}
\index{bus\_\-get\_\-device\_\-count@{bus\_\-get\_\-device\_\-count}!bus.h@{bus.h}}
\subsubsection[{bus\_\-get\_\-device\_\-count}]{\setlength{\rightskip}{0pt plus 5cm}unsigned char bus\_\-get\_\-device\_\-count (void)}}
\label{bus_8h_76f9639571632344a2a1ae4138663667}


Receive the device count on the bus. 

\begin{Desc}
\item[Returns:]The number of devices on the bus \end{Desc}


Definition at line 235 of file bus.c.

References bus\_\-status\_\-struct::device\_\-count.

Referenced by main().\hypertarget{bus_8h_ce52a77ee7a62558643de23c5f10f9c7}{
\index{bus.h@{bus.h}!bus\_\-is\_\-master@{bus\_\-is\_\-master}}
\index{bus\_\-is\_\-master@{bus\_\-is\_\-master}!bus.h@{bus.h}}
\subsubsection[{bus\_\-is\_\-master}]{\setlength{\rightskip}{0pt plus 5cm}unsigned char bus\_\-is\_\-master (void)}}
\label{bus_8h_ce52a77ee7a62558643de23c5f10f9c7}


Returns if the bus is set to be master. 

\begin{Desc}
\item[Returns:]1 if it is configured to be master, 0 otherwise \end{Desc}


Definition at line 196 of file bus.c.

References BUS\_\-STATUS\_\-DEVICE\_\-IS\_\-MASTER\_\-BIT, and bus\_\-status\_\-struct::flags.

Referenced by ISR(), and main().\hypertarget{bus_8h_4541ef9a75addac3aaa4af88d8f03590}{
\index{bus.h@{bus.h}!bus\_\-message\_\-nacked@{bus\_\-message\_\-nacked}}
\index{bus\_\-message\_\-nacked@{bus\_\-message\_\-nacked}!bus.h@{bus.h}}
\subsubsection[{bus\_\-message\_\-nacked}]{\setlength{\rightskip}{0pt plus 5cm}void bus\_\-message\_\-nacked (unsigned char {\em addr}, \/  unsigned char {\em error\_\-type})}}
\label{bus_8h_4541ef9a75addac3aaa4af88d8f03590}


The message last sent was NACKED from the receiver. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em addr}]The address of the device that sent the NACK \item[{\em error\_\-type}]Contains information why the message was NACKED \end{description}
\end{Desc}


Definition at line 348 of file bus.c.

References bus\_\-resend\_\-message(), BUS\_\-STATUS\_\-MESSAGE\_\-ACK\_\-TIMEOUT, bus\_\-status\_\-struct::flags, BUS\_\-MESSAGE::to\_\-addr, and tx\_\-queue\_\-get().

Referenced by bus\_\-parse\_\-message(), and event\_\-bus\_\-parse\_\-message().\hypertarget{bus_8h_651be0f483dc1e17174069bbf991d653}{
\index{bus.h@{bus.h}!bus\_\-send\_\-nack@{bus\_\-send\_\-nack}}
\index{bus\_\-send\_\-nack@{bus\_\-send\_\-nack}!bus.h@{bus.h}}
\subsubsection[{bus\_\-send\_\-nack}]{\setlength{\rightskip}{0pt plus 5cm}void bus\_\-send\_\-nack (unsigned char {\em to\_\-addr}, \/  unsigned char {\em error\_\-type})}}
\label{bus_8h_651be0f483dc1e17174069bbf991d653}


Send an NOT acknowledge. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em to\_\-addr}]Which address we wish to send the ping to \item[{\em error\_\-type}]Why was the message nacked, see \hyperlink{bus_8h}{bus.h} for more information about BUS errors \end{description}
\end{Desc}


Definition at line 223 of file bus.c.

References bus\_\-add\_\-tx\_\-message(), BUS\_\-BROADCAST\_\-ADDR, BUS\_\-CMD\_\-NACK, and bus\_\-status\_\-struct::ext\_\-addr.

Referenced by ISR().\hypertarget{bus_8h_9869a6434da36c0bfa8573d68bed9b40}{
\index{bus.h@{bus.h}!bus\_\-set\_\-address@{bus\_\-set\_\-address}}
\index{bus\_\-set\_\-address@{bus\_\-set\_\-address}!bus.h@{bus.h}}
\subsubsection[{bus\_\-set\_\-address}]{\setlength{\rightskip}{0pt plus 5cm}void bus\_\-set\_\-address (unsigned char {\em addr})}}
\label{bus_8h_9869a6434da36c0bfa8573d68bed9b40}


Set the address of this device on the bus. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em addr}]The address of this device \end{description}
\end{Desc}


Definition at line 108 of file bus.c.

References bus\_\-status\_\-struct::ext\_\-addr.

Referenced by main().\hypertarget{bus_8h_bbcb4456ec66651e191189cc985bfeab}{
\index{bus.h@{bus.h}!bus\_\-set\_\-device\_\-count@{bus\_\-set\_\-device\_\-count}}
\index{bus\_\-set\_\-device\_\-count@{bus\_\-set\_\-device\_\-count}!bus.h@{bus.h}}
\subsubsection[{bus\_\-set\_\-device\_\-count}]{\setlength{\rightskip}{0pt plus 5cm}void bus\_\-set\_\-device\_\-count (unsigned char {\em device\_\-count})}}
\label{bus_8h_bbcb4456ec66651e191189cc985bfeab}


Set the number of devices that are on the bus. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em device\_\-count}]The number of devices on the bus, ie the number of time slots \end{description}
\end{Desc}


Definition at line 241 of file bus.c.

References BUS\_\-TIME\_\-MULTIPLIER, bus\_\-status\_\-struct::device\_\-count, and bus\_\-status\_\-struct::device\_\-count\_\-mult.\hypertarget{bus_8h_ed493aabe32ac3eaafb77d4c23f15eb9}{
\index{bus.h@{bus.h}!bus\_\-set\_\-is\_\-master@{bus\_\-set\_\-is\_\-master}}
\index{bus\_\-set\_\-is\_\-master@{bus\_\-set\_\-is\_\-master}!bus.h@{bus.h}}
\subsubsection[{bus\_\-set\_\-is\_\-master}]{\setlength{\rightskip}{0pt plus 5cm}void bus\_\-set\_\-is\_\-master (unsigned char {\em state}, \/  unsigned char {\em count})}}
\label{bus_8h_ed493aabe32ac3eaafb77d4c23f15eb9}


Set the status if the device should be master or not. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em state}]1 if you wish the device to be master, 0 if you wish that it should be slave \item[{\em count}]The nr of devices \end{description}
\end{Desc}


Definition at line 206 of file bus.c.

References BUS\_\-STATUS\_\-ALLOWED\_\-TO\_\-SEND\_\-BIT, BUS\_\-STATUS\_\-DEVICE\_\-IS\_\-MASTER\_\-BIT, BUS\_\-STATUS\_\-FORCE\_\-SYNC, BUS\_\-TIME\_\-MULTIPLIER, bus\_\-status\_\-struct::device\_\-count, bus\_\-status\_\-struct::device\_\-count\_\-mult, and bus\_\-status\_\-struct::flags.

Referenced by main().